package sort.MaxPQ;

import java.util.Arrays;

import static sort.SortCompare.getArray;
// 找最小的3个数字
public class TopM {
    public static void main(String[] args) {
        Double[] array = (Double[]) getArray(10);
        System.out.println(Arrays.asList(array));
        // 取最小的三个
        MaxPQ<Double> pq = new MaxPQ<>(4);
        for (int i = 0; i < array.length; i++) {
            pq.insert(array[i]);
            if (pq.size() > 3) {
                Double max = pq.delMax();
                System.out.println(max);
            }
        }

        while (!pq.isEmpty()) {
            System.out.print(pq.delMax() + " ");
        }
    }
}
